{% extends "./base.html" %}
{% block title %}Ratings{% endblock %}
{% block content %}

<div id="returnto">
	Return to <a href="{{ uri.relPath('..') }}">{{ title }}</a>
</div>

<h1>Ratings for {{ title }}</h1>

{% if user %}
	<div id="createRating">
		<form action="" method="post">
			<label for="rating">Rating:</label> <input type="range" min="1" max="100" name="rating" value="0" />
			<br />
			<label for="comments">Comments:</label>
			<br />
			<textarea name="comments"></textarea>
			<br />
			<input type="submit" />
		</form>
	</div>
{% endif %}

<ol>
	{% for rating in ratings %}
	<li>
		<a href="{{ uri.absPath('users', rating.rater_obj.key().id() ) }}">{{ rating.rater_obj.getName() }}</a>
		(<a href="{{ uri.absPath('users', rating.rater_obj.key().id(), 'ratings' ) }}">Ratings</a>): <input type="range" disabled="disabled" min="0" max="100" value="{{ rating.rating }}" /> ({{ rating.rating }})
		{% if user.admin or rating.rater == user.id -%}
			- <form action="" method="post" style="display:inline">
				<input type="hidden" name="action" value="delete" />
				<input type="submit" value="Delete" />
			</form>
		{%- endif %}
		<div class="comments">
			{{ rating.comments }}
		</div>
	</li>
	{% endfor %}
</ol>
{% endblock %}
